#include <ctime>
#include <iostream>
#include <fstream>
using namespace std;
void bs(int li[], int l)
{
    while(l--)
    {
        bool sw = false;
        for(int i; i < l;i++)
        {
            if(li[i]>li[i+1])
            {
                swap(li[i],li[i+1]);
                sw = true;
            }
        }
        if(sw==false) break;
    }
}
void rf(const char *filename, int a[], int len)
{
    ifstream file(filename);
    for(int i =0; i < len; i++)
        file >> a[i];
}
int main()
{
    const int LEN = 5000;
    int a[LEN];
    int a1[LEN];
    int a2[LEN];
    rf("m1_sorted.txt",a,LEN);
    unsigned int ts = clock();
    bs(a,LEN);
    unsigned int tf = clock();
    unsigned int tw = tf-ts;
    cout << "m1_sorted " << tw << " milliseconds \n" << endl;
    rf("m2_sorted.txt",a1,LEN);
    unsigned int ts1 = clock();
    bs(a1,LEN);
    unsigned int tf1 = clock();
    unsigned int tw1 = tf1-ts1;
    cout << "m2_sorted " << tw1 << " milliseconds \n" << endl;
    rf("m3_sorted.txt",a2,LEN);
    unsigned int ts2 = clock();
    bs(a2,LEN);
    unsigned int tf2 = clock();
    unsigned int tw2 = tf2-ts2;
    cout << "m3_sorted " << tw2 << " milliseconds \n" << endl;
    return 0;
}
